package com.quanyan.place.web;

import com.quanyan.api.APIResponse;
import com.quanyan.place.entity.TbBizPlaceAttachLabel;
import com.quanyan.place.entity.TbLabel;
import com.quanyan.place.entity.vo.PlaceFromDataVo;
import com.quanyan.place.entity.vo.ReqPlaceLabel;
import com.quanyan.place.service.BaseService;
import com.quanyan.place.service.PlaceLabelService;
import org.apache.commons.collections.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * Created by yangyun on 2017/5/26.
 */
@RestController
@RequestMapping("/admin/api/place/label")
public class PlaceLabelController {

    @Autowired
    PlaceLabelService placeLabelService;

    /**
     * 场馆标签设置
     * @param reqPlaceLabel
     * @return
     */
    @RequestMapping(value = "/saveOrUpdatePlaceLabel", method = RequestMethod.POST)
    public APIResponse<?> saveOrUpdatePlaceLabel(@RequestBody ReqPlaceLabel reqPlaceLabel)  {
        APIResponse apiResponse = placeLabelService.saveOrUpdatePlaceLabel(reqPlaceLabel);
        return apiResponse;
    }

    @RequestMapping(value = "/getPlaceCommonLabel")
    public APIResponse<?> getPlaceCommonLabel(){
        Map<Byte,List<TbLabel>> tbLabelMap= placeLabelService.getPlaceCommonLabel();
        return APIResponse.returnSuccess(tbLabelMap);
    }

    @RequestMapping(value = "/getPlaceLabel",method = RequestMethod.POST)
    public APIResponse<?> getPlaceLabel(@RequestBody Map<String, Object> map) {
        Integer placeId = MapUtils.getInteger(map, "placeId");
        //List<TbBizPlaceAttachLabel> tbBizPlaceLabelList= placeLabelService.getPlaceLabel(placeId,null);
        Map<Byte,List<TbBizPlaceAttachLabel>> tbLabelMap= placeLabelService.getPlaceLabelByPlaceId(placeId);
        return APIResponse.returnSuccess(tbLabelMap);
    }

}
